home *** CD-ROM | disk | FTP | other *** search
/ Developer Helper 1: Phil & Dave's Excellent CD / Excellent CD HFS.raw / Moof / Goodies / HyperCard Goodies / AppleTalk Stuff / HyperAppleTalk / ATP / ATPReceive.c < prev    next >
Text File  |  1988-02-10  |  3KB  |  100 lines

  1. /*******************************************************************\
  2. *    file:         ATPReceive.c                                        *
  3. *    version:    1.06ß                                                *
  4. *                                                                    *
  5. * return any responses that were received via the GetRequest queue    *
  6. *                                                                     *
  7. * -----------------------------------------------------------------    *
  8. * By:    Donald Koscheka, Greg Kimberly                                *
  9. * Date:    24-Sept-87                                                    *
  10. * ©    Copyright 1987, Apple Computer, Inc.                            *
  11. *    All Rights Reserved                                                *
  12. *                                                                    *
  13. * -----------------------------------------------------------------    *
  14. *                        Modification History                        *
  15. * -----------------------------------------------------------------    *
  16. *  Date           | By    |                     Description                    *
  17. * -----------------------------------------------------------------    *
  18. * 25-Sep-87    | GK    | file created                                    *
  19. *  5-Nov-87    | DK    | added return result                            *
  20. * 21-Dec-87    | DK    | if response meesage is empty, set handle to 0    *
  21. * 11-Jan-88    | DK    | modified to reflect decoupling of ATP & NBP    *
  22. * 10-Feb-88    | DK    | added a checkpoint flag that receive sets to     *
  23. *            |         | tell close not to call (because ATPClose can    *
  24. *            |         | called from a callback).                        *
  25. * -----------------------------------------------------------------    *
  26. \*******************************************************************/
  27.  
  28. /*******************************************************************\
  29.                             Build Sequence
  30.     
  31. C -q2 -g -o "{hpo}"ATPReceive.c.o "{atp}"ATPReceive.c
  32.     link  -sn Main=ATPReceive -sn STDIO=ATPReceive ∂
  33.          -sn INTENV=ATPReceive -rt XCMD=304 ∂
  34.          -m ATPRECEIVE ∂
  35.          "{hpo}"ATPReceive.c.o  "{hpo}"atalkxcmd.c.o "{hpo}"xcmdutils.c.o ∂
  36.          "{CLibraries}"CInterface.o ∂
  37.          "{Libraries}"Interface.o ∂
  38.          -o "{hp}"HyperPeople
  39.  
  40. \*******************************************************************/
  41.  
  42. #include <Types.h>
  43. #include <Memory.h>
  44. #include <Resources.h>
  45. #include <OSUtils.h>
  46. #include <appleTalk.h>
  47. #include <HyperXCmd.h>
  48. #include <atalkXCMD.h>
  49. #include <XCMDUtils.h>
  50.  
  51.  
  52. pascal void ATPReceive(paramPtr)
  53.     XCmdBlockPtr    paramPtr;
  54. /*********************************
  55. * ATReceive()
  56. *
  57. * Receive handle requests on the server side
  58. * and responses on the client side.  If a
  59. * queued request completes, hypercard is called
  60. * back with the message.
  61. *
  62. * In:    paramPtr->params[0] == message to send on getrequest 
  63. *                                
  64. * Out:    OSErr.
  65. *
  66. *********************************/
  67. {
  68.     ATPBlock    *atp;
  69.     short        nextelem;
  70.     short        result = NO_ERROR;
  71.     Handle        rMess;
  72.     
  73.     atp = (ATPBlock *)RetrieveHandle( paramPtr, GLOBALATPDATA );
  74.     
  75.     if( !atp ){
  76.         paramPtr->returnValue = ErrorReturn(  result );
  77.         return;
  78.     }
  79.     
  80.     atp->checkPoint = RECEIVING;
  81.     
  82.     rMess = paramPtr->params[0];
  83.     if( !rMess || !**rMess )
  84.         rMess = nil;
  85.     
  86.     
  87.     result = PollRequests( paramPtr, atp, rMess );
  88.     
  89.     if( atp->checkPoint == CLOSE_NOW ){    /*** ATPClose was called from a callback ***/
  90.         result = ATPKill( atp );
  91.         SaveHandle( paramPtr, GLOBALATPDATA, nil );
  92.     }
  93.     else
  94.         atp->checkPoint = CLOSE_OK;
  95.         
  96.     paramPtr->returnValue = ErrorReturn(  result );
  97. }
  98.  
  99.  
  100.